package com.yida.gwj.vote.service.impl;


import com.yida.common.core.utils.DateUtils;
import com.yida.common.security.utils.SecurityUtils;
import com.yida.gwj.vote.domain.GwjVoteHouse;
import com.yida.gwj.vote.mapper.GwjVoteHouseMapper;
import com.yida.gwj.vote.service.IGwjVoteHouseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 投票房屋Service业务层处理
 *
 * @author lqq
 * @date 2023-03-22
 */
@Service
public class GwjVoteHouseServiceImpl implements IGwjVoteHouseService {

	@Resource
	private GwjVoteHouseMapper voteHouseMapper;

	/**
	 * 查询投票房屋
	 *
	 * @param voteHouseId 投票房屋主键
	 * @return 投票房屋
	 */
	@Override
	public GwjVoteHouse selectVoteHouseByVoteHouseId(Long voteHouseId) {
		return voteHouseMapper.selectVoteHouseByVoteHouseId(voteHouseId);
	}

	/**
	 * 查询投票房屋列表
	 *
	 * @param voteHouse 投票房屋
	 * @return 投票房屋
	 */
	@Override
	public List<GwjVoteHouse> selectVoteHouseList(GwjVoteHouse voteHouse) {
		return voteHouseMapper.selectVoteHouseList(voteHouse);
	}

	/**
	 * 新增投票房屋
	 *
	 * @param voteHouse 投票房屋
	 * @return 结果
	 */
	@Override
	public int insertVoteHouse(GwjVoteHouse voteHouse) {
		voteHouse.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getRealName());
		voteHouse.setCreateTime(DateUtils.getNowDate());
		return voteHouseMapper.insertVoteHouse(voteHouse);
	}

	/**
	 * 新增投票房屋
	 *
	 * @param voteHouses 投票房屋
	 * @return 结果
	 */
	@Override
	public int insertBatchVoteHouse(List<GwjVoteHouse> voteHouses) {
		return voteHouseMapper.insertBatchVoteHouse(voteHouses);
	}

	/**
	 * 修改投票房屋
	 *
	 * @param voteHouse 投票房屋
	 * @return 结果
	 */
	@Override
	public int updateVoteHouse(GwjVoteHouse voteHouse) {
		voteHouse.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getRealName());
		voteHouse.setUpdateTime(DateUtils.getNowDate());
		return voteHouseMapper.updateVoteHouse(voteHouse);
	}

	/**
	 * 批量删除投票房屋
	 *
	 * @param voteHouseIds 需要删除的投票房屋主键
	 * @return 结果
	 */
	@Override
	public int deleteVoteHouseByVoteHouseIds(Long[] voteHouseIds) {
		return voteHouseMapper.deleteVoteHouseByVoteHouseIds(voteHouseIds);
	}

	/**
	 * 删除投票房屋信息
	 *
	 * @param voteHouseId 投票房屋主键
	 * @return 结果
	 */
	@Override
	public int deleteVoteHouseByVoteHouseId(Long voteHouseId) {
		return voteHouseMapper.deleteVoteHouseByVoteHouseId(voteHouseId);
	}

	/**
	 * 修改投票房屋选择状态
	 *
	 * @param voteHouseIds 投票房屋主键
	 * @param selectFlag   是否选择
	 * @return 结果
	 */
	@Override
	public int updateBatchVoteHouseSelectFlag(Long[] voteHouseIds, String selectFlag) {
		return voteHouseMapper.updateBatchVoteHouseSelectFlag(voteHouseIds, selectFlag, DateUtils.getNowDate(), SecurityUtils.getLoginUser().getSysUser().getRealName());
	}
}
